import {request} from '@umijs/max';
import * as API from "@/services";
import {PageQueryParams} from "kf-web-library";


/** 文章收藏 分页检索请求 */
export async function queryArticleCollections(params: API.ArticleCollectionPageQueryParams): Promise<API.RespPageResult<API.ArticleCollection>> {
  return request('/api/v1/article-collection', {
    params,
  });
}

/** 文章收藏 详情请求 */
export async function queryArticleCollection(bizId: API.EntityId): Promise<API.RespResult<API.ArticleCollection>> {
  return request(`/api/v1/article-collection/${bizId}`);
}


/** 文章收藏（当前用户） */
export async function collectionArticleReq(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/article-collection/${bizId}/collection`, {
    method: 'PATCH',
  });
}

/** 取消文章收藏（当前用户） */
export async function unCollectionArticleReq(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/article-collection/${bizId}/uncollection`, {
    method: 'PATCH',
  });
}

/** 文章是否被收藏（当前用户） */
export async function hasCollectionArticleReq(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/article-collection/${bizId}/hascollection`, {
    method: 'PATCH',
  });
}

/** 文章被收藏数量 */
export async function queryArticleCollectionNum(bizId: API.EntityId): Promise<API.RespResult<number>> {
  return request(`/api/v1/article-collection/${bizId}/collectionnum`, {
    method: 'PATCH',
  });
}


/** 我的收藏列表 */
export async function queryMyArticleCollections(params: API.PageQueryParams): Promise<API.RespPageResult<API.ArticleCollection>> {
  return request(`/api/v1/article-collection/mycollection`, {
    method: 'GET',
    params,
  });
}

